<template>
	<view class="">
		<cu-custom bgColor="bg-gradual-green" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">温其如玉</block>
		</cu-custom>
		<view class="padding" style="min-height: 84vh">
			<view class="margin-sm poetry">
				<view class="text-title text-bold margin-bottom-xs padding-bottom-xs u-border-bottom ">{{ poetry.title }}</view>
				<view class="flex  flex-direction align-start padding-left padding-bottom-sm ">
					<text>—— {{poetry.author}}</text>
				</view>
				<u-parse :html="poetry.contentFormat" :selectable="true"></u-parse>
				<u-gap height="80" ></u-gap>
				<view class="flex margin-top flex-direction ">
					<text>{{$u.timeFormat(new Date(poetry.createTime).getTime(), 'yyyy-mm-dd')}}</text>
				</view>
			</view>
		</view>
		<share :article="poetry"></share>
		<u-gap height="20"></u-gap>
		<view class="padding">
			<comment :articleId="articleId"></comment>
		</view>
	</view>
	
</template>

<script>
import comment from '@/components/yr/comment/comment.vue'
import share from '@/components/yr/share/share.vue'
export default {
	components:{
		comment,share
	},
	data() {
		return {
			articleId:'',
			poetry: {}
		};
	},
	onLoad(option) {
		this.articleId = option.id;
		this.getPoetry(option.id);
		wx.showShareMenu({
			withShareTicket:true,
			//设置下方的Menus菜单，才能够让发送给朋友与分享到朋友圈两个按钮可以点击
			menus:["shareAppMessage","shareTimeline"]
		})
	},
	//发送给朋友
	onShareAppMessage(res) {
		// 此处的distSource为分享者的部分信息，需要传递给其他人
		return {
			title: this.poetry.title,
			type: 0,
			path: '/pages/home/poetry_content/poetry_content?id='+this.poetry.id,
			summary: "",
			imageUrl: this.poetry.cover
		}
	},
	//分享到朋友圈
	onShareTimeline(res) {
		return {
			title: this.poetry.title,
			type: 0,
			query: 'id='+this.poetry.id,
			summary: "",
			imageUrl: this.poetry.cover
		}
	},
	methods: {
		getPoetry(id) {
			this.$u.api.getArticle(id).then(res => {
				this.poetry = res.data;
			});
		}
	}
};
</script>

<style lang="stylus">
page
	background #FFFFFF
.text-title
	font-size 34rpx
.poetry
	background #f7f7f7
	padding 34rpx 24rpx
	border-radius 15rpx
</style>
